Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add example mock "kubectl get configmap xx -o json" #639

Closed
wants to merge 5 commits into from
Closed

add example mock "kubectl get configmap xx -o json" #639

wants to merge 5 commits into from

Conversation

ZP-AlwaysWin
Copy link

add example mock "kubectl get configmap xx -o json"

@k8s-ci-robot
Copy link
Contributor

Welcome @ZP-AlwaysWin!

It looks like this is your first PR to kubernetes-client/java 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-client/java has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jul 28, 2019
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jul 28, 2019
@ZP-AlwaysWin
Copy link
Author

/assign @mbohlool

*
* <p>From inside $REPO_DIR/examples
*
* <p>mock "kubectl get configamp configmap-name -o json"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the point of adding this example? i don't think this example worth a new file..

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @yue9944882
I use java-client to work for pass platform, I need to get xxx.json to change, mock kubectl get resourcename -o json。but Under the existing examples,I don't konw how to do it. Stand in the user's Perspective ,I add example。

It's up to you to decide.

Best Wishes

@brendandburns
Copy link
Contributor

This is probably a good thing to add to the ParseExample.java instead of a brand new example.

Thanks!

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 30, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: ZP-AlwaysWin
To complete the pull request process, please assign mbohlool
You can assign the PR to them by writing /assign @mbohlool in a comment when ready.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jul 30, 2019
@ZP-AlwaysWin
Copy link
Author

This is probably a good thing to add to the ParseExample.java instead of a brand new example.

Thanks!

hi @brendandburns

I already add the example to the ParseExample.java, I am using the java-client to work for paas , If I find any minor problems or usability problems, I will contribute.

Best Wishes


String body = response.body().string();

JsonObject returnData = new JsonParser().parse(body).getAsJsonObject();
Copy link
Member

@yue9944882 yue9944882 Jul 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will this work with the custom-type adapter? in the existing example, it's parsing by using the nested gson instance where we register the adapters?

    Object obj2 = client
            .getJSON()	

Copy link
Contributor

@brendandburns brendandburns Jul 31, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hrm, I think that Gson adapters are injected via annotation so that they would work everywhere, e.g. https://github.com/kubernetes-client/java/blob/master/kubernetes/src/main/java/io/kubernetes/client/custom/Quantity.java#L14

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public JSON() {
gson = new GsonBuilder()
.registerTypeAdapter(Date.class, dateTypeAdapter)
.registerTypeAdapter(java.sql.Date.class, sqlDateTypeAdapter)
.registerTypeAdapter(DateTime.class, dateTimeTypeAdapter)
.registerTypeAdapter(LocalDate.class, localDateTypeAdapter)
.registerTypeAdapter(byte[].class, byteArrayTypeAdapter)
.create();
}

but here we're registering the adapters explicitly

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, that's true for those built-ins we can't annotate...

@brendandburns
Copy link
Contributor

Closing this since it is old. Please feel free to re-open if there are updates.

@ZP-AlwaysWin ZP-AlwaysWin deleted the dev01 branch October 23, 2019 02:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants